import request from '@/utils/http'
import { PaginationResult, BaseResult } from '@/types/axios'
import { ActivityType } from './model/activityModel'

// 活动
export class ActivityService {
    // 获取活动列表
    static getActivityList(params: any) {
        const { page, size, searchVal, year } = params
        return request.get<PaginationResult<ActivityType[]>>({
            url: `/api/activities/${page}/${size}?title=${searchVal}&year=${year}`
        })
    }

    // 分页获取活动列表
    static getActivityListByType(params: any) {
        return request.post<PaginationResult<ActivityType[]>>({
            url: `/scenicAreaApi/scenic/activity/pageActivity`,
            data: params
        })
    }

    // 获取活动详情
    static getActivityDetail(id: number) {
        return request.get<BaseResult<ActivityType>>({
            url: `/api/activities/${id}`
        })
    }

    // 新增活动
    static addActivity(params: any) {
        return request.post<BaseResult>({
            url: '/api/activities/',
            data: params
        })
    }

    // 编辑活动
    static editActivity(id: number, params: any) {
        return request.put<BaseResult>({
            url: `/api/activities/${id}`,
            data: params
        })
    }

    // 活动预约
    static reserveActivity(params: any) {
        return request.post<BaseResult>({
            url: '/api/activities/reserve',
            data: params
        })
    }

    // 获取预约列表
    static getReservationList(params: any) {
        return request.post<PaginationResult<any>>({
            url: '/api/activities/reservations',
            data: params
        })
    }
}
